<#assign module="workcar"/>

<@override name="header">
</@override>
<@override name="body">
<div class="row">
  <div class="col-xs-10">
  	
  	<div class="btn-group">
	  <a class="btn btn-default" href="${ctx}/workcarpickup/list">接送记录</a>
	  <@shiro.isMainCompany>
	  <a class="btn btn-default" href="${ctx}/workcararea/list">工作车路线</a>
	  </@shiro.isMainCompany>
	  <a class="btn btn-default active" href="${ctx}/workcar/list">工作车</a>
	</div>
  	
  </div>
  <div class="col-xs-2">
  	<button class="pull-right btn btn-primary" onclick="window.location='${ctx}/workcar/add';"><b>+</b>&nbsp;添加新工作车</button>
  </div>
</div>
<div class="row margin-top">
	<div class="col-xs-12">
	<div class="panel panel-primary">
	<div class="table-responsive">
		<table class="table table-hover table-striped">
			<thead>
				<tr style="font-size:14px;">
				    <th>工作车名字</th>
					<th>车牌号</th>
					<th>车型</th>
					<th>费用</th>
					<th>状态</th>
					<th>当前服务人员</th>
					<th>工作路线</th>
					<@shiro.isMainCompany>
					<th>所属公司</th>
					</@shiro.isMainCompany>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<#if (page.content)?? >
			  	<#list page.content as data>
					<tr>
					    <td>${data.workCarName?if_exists}</td>
						<td>${data.plateNumber?if_exists}</td>
						<td>${data.carType?if_exists}</td>
						<td>${data.fixedMoney?if_exists}</td>
						<td>
							<#if data.status==0>
								未指派
							<#elseif data.status==1>
								空闲
							<#elseif data.status==2>
								忙碌
							</#if>
						</td>
						<td>
							${data.currentDriverName!"-"}
						</td>
						<td>
							<#if data.workCarArea??>
								${data.workCarArea.city?if_exists}-${data.workCarArea.name?if_exists}
							<#else>
								-
							</#if>
						</td>
						<@shiro.isMainCompany>
						<td>${data.companyName?if_exists}</td>
						</@shiro.isMainCompany>
						<td>
							<a href="${ctx}/workcar/edit/${data.id}" class="btn-link">编辑</a>
							<a href="javascript:;" data-value="${data.id}" class="btn-link deletethis">删除</a>
							<a href="${ctx}/workcar/appoint/${data.id}" class="btn-link">指派服务人员</a>
						</td>
					</tr>
				</#list>
				</#if>
			</tbody>
		</table>
		<#if page.totalElements??>
		<ul class="pagination pull-right pagination-sm">
			<li><a>共 ${page.totalElements} 条数据</a></li>
			<@pg.pager items=page.totalElements?number maxPageItems=20 export="currentPageNumber=pageNumber" url="${ctx}/workcar/list">
				<@pg.index>
					<@pg.first>
						<li><a href="${pageUrl}">&laquo;</a></li>
					</@pg.first>
					<@pg.prev>
						<li><a href="${pageUrl}">&lsaquo;</a></li>
					</@pg.prev>
					<@pg.pages>
						<#if  currentPageNumber == pageNumber >
							<li class="active"><a href="#">${pageNumber}</a></li>
						<#else>
							<li><a href="${pageUrl}">${pageNumber}</a></li>
						</#if>
					</@pg.pages>
					<@pg.next>
						<li><a href="${pageUrl}">&rsaquo;</a></li>
					</@pg.next>
					<@pg.last>
						<li><a href="${pageUrl}">&raquo;</a></li>
					</@pg.last>
				</@pg.index>
			</@pg.pager>
		</ul>
		</#if>
	</div>
	</div>
	</div>
</div>
</@override>

<@override name="footer">
	<script type="text/javascript">
		window.daijia = {
			ctx:'${ctx}',
			userId:'<@shiro.principal property='id'/>'
		};
	</script>
	<script src="${ctx}/assets/js/pushmessage.js"></script>
	<script type="text/javascript">
		var thisButton;
		function deleteWorkCar() {
		    $.post('${ctx}/workcar/delete',{'id':thisButton.attr("data-value")},function(data){
		            if(data.success){
		            	thisButton.parent().parent().remove();
		                $.scojs_message('工作车删除成功', $.scojs_message.TYPE_OK);
		            } else {
		                $.scojs_message(data.message, $.scojs_message.TYPE_ERROR);
		            }
		    },'json');
		}
		$(document).ready(function(){
		    $(".deletethis").click(function(){
		          thisButton = $(this);
		          var confirm = $.scojs_confirm({
		            content: "你真的要删除该工作车吗？",
		            action:deleteWorkCar
		          });
		          confirm.show();
		    });
		});
	</script>
</@override>
<@extends name="../layout.ftl"/>